package com.hyt.it.ogt.controller.ykcj.exam;

import com.hyt.it.ogt.controller.base.BaseController;
import com.hyt.it.ogt.ykcj.common.annotation.Log;
import com.hyt.it.ogt.ykcj.common.core.domain.AjaxResult;
import com.hyt.it.ogt.ykcj.common.enums.BusinessType;
import com.hyt.it.ogt.ykcj.domain.param.EnterpriseScoreLineListParam;
import com.hyt.it.ogt.ykcj.domain.param.EnterpriseScoreLineQueryParam;
import com.hyt.it.ogt.ykcj.domain.param.EnterpriseScoreLineSaveParam;
import com.hyt.it.ogt.ykcj.service.exam.IEnterpriseExamScoreLineSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企业招聘考试信息Controller
 *
 * @author admin
 * @date 2021-06-18
 */
@Api(tags = "exam.11.企业招聘考试分数线信息", value = "企业招聘考试分数线信息请求接口")
@ApiSort(value = 111)
@RestController
@RequestMapping("/enterprise/scoreLine")
public class EnterpriseExamScoreLineController extends BaseController {
    @Autowired
    private IEnterpriseExamScoreLineSettingService enterpriseExamScoreLineSettingService;

    /**
     * 新增分数线
     */
    @ApiOperation("新增分数线")
    @Log(title = "新增分数线", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult add(@RequestBody EnterpriseScoreLineListParam enterpriseScoreLineListParam) {
        enterpriseExamScoreLineSettingService.createScoreLineBatch(enterpriseScoreLineListParam);
        return AjaxResult.success();
    }

    /**
     * 新增分数线
     */
    @ApiOperation("追加分数线")
    @Log(title = "追加分数线", businessType = BusinessType.INSERT)
    @PostMapping("/addTo")
    public AjaxResult addTo(@RequestBody EnterpriseScoreLineSaveParam enterpriseScoreLineSaveParam) {
        enterpriseExamScoreLineSettingService.addToScoreLine(enterpriseScoreLineSaveParam);
        return AjaxResult.success();
    }

    /**
     * 列表页
     */
    @ApiOperation("分数线列表")
    @Log(title = "分数线列表", businessType = BusinessType.INSERT)
    @PostMapping("/list")
    public AjaxResult list(@RequestBody EnterpriseScoreLineQueryParam enterpriseScoreLineQueryParam) {
        EnterpriseScoreLineListParam result = enterpriseExamScoreLineSettingService
                .getScoreLineVOList(enterpriseScoreLineQueryParam.getExamId(), enterpriseScoreLineQueryParam.getDimension(),
                        enterpriseScoreLineQueryParam.getSubjectId());
        return AjaxResult.success(result);
    }

    /**
     * 删除考试信息
     *
     * @throws Exception
     */
    @ApiOperation("删除分数线信息")
    @Log(title = "删除分数线信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable String id) {
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("参数不能为空");
        }
        enterpriseExamScoreLineSettingService.deleteScoreLineById(id);
        return AjaxResult.success();
    }

    /**
     * 新增分数线
     */
    @ApiOperation("批量修改分数线")
    @Log(title = "批量修改分数线", businessType = BusinessType.INSERT)
    @PostMapping("/saveBatch")
    public AjaxResult saveBatch(@RequestBody List<EnterpriseScoreLineSaveParam> enterpriseExamInsertParamList) {
        enterpriseExamScoreLineSettingService.saveBatch(enterpriseExamInsertParamList);
        return AjaxResult.success();
    }

}


